<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>有序数组中出现次数超过百分之二十五的元素</title>
</head>
<body>
  <script>
    function fn(arr) {
      if (arr.length <= 3) return arr[0]
      let num = Math.ceil(arr.length * 0.25);
      let num1 = 0
      for (let i = 0; i < arr.length - 1; i++) {
        arr[i] === arr[i + 1] ? num1++ : num1 = 0
        if (num === num1) {
          return arr[i]
        }
      }
    }
    console.log(fn)
  </script>
</body>
</html>